<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=request.getContextPath()%>/css/base.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.validate.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.validate.methods.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/base.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/admin.js"></script>
<script src="<%=request.getContextPath()%>/js/jquery.uploadify.v2.1.4.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/swfobject.js" type="text/javascript"></script>
<link href="<%=request.getContextPath()%>/js/uploadify.css" rel="stylesheet" type="text/css" />
</head>


<BODY class="input" sizcache="0" sizset="0" ><DIV class=bar>修改广告信息</DIV>
<div id="validateErrorContainer" class="validateErrorContainer">
		<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
		<ul></ul>
	</div>

<DIV class=body sizcache="0" sizset="0">
<FORM id=advForm  method=post action=advsave.do sizcache="0" sizset="0" >
<TABLE  class="inputTable" sizcache="0" sizset="0" >
<TBODY sizcache="0" sizset="0">
<input type="hidden" name="id" value="${adv.id}" />
<TR class=noneHover>
<TD ><INPUT type="file" name="uploadify" id="uploadify"  />    建议图片尺寸：700*300 </TD>

<TD>图片名称：<input type="text" name="imgName" id="imgName" value="${adv.imgName}" readonly/></TD></TR>
<TR>
<TD ><img class=advimg src="<%=request.getContextPath()%>${adv.imgName}" width="500px" height="250px"></TD>

<TD>
 <TABLE>
   <TR><TD>主链接：</TD><TD><INPUT class=formText style="width:280px"  type=text maxlength="50" name=link value=${adv.link}></TD></TR>
   <TR><TD>link1：</TD><TD><INPUT class=formText style="width:280px"  type=text maxlength="50" name=link1 value=${adv.link1}></TD></TR>
   <TR><TD>link2：</TD><TD><INPUT class=formText style="width:280px"  type=text maxlength="50" name=link2 value=${adv.link2}></TD></TR>
   <TR><TD>link3：</TD><TD><INPUT class=formText style="width:280px"  type=text maxlength="50" name=link3 value=${adv.link3}></TD></TR>
   <TR><TD>link4：</TD><TD><INPUT class=formText style="width:280px"  type=text maxlength="50" name=link4 value=${adv.link4}></TD></TR>
   <TR><TD>排序:<INPUT class=formText style="width:10px" maxlength="1" type=text name=sort value=${adv.sort}></TD>
   <TD>是否显示:<SELECT name=status id=status> 
     <OPTION selected value="1"  ${adv.status==1?'selected':''}>是</OPTION> <OPTION value="0" ${adv.status==0?'selected':''}>否</OPTION></SELECT>
     </TD>
   </TR>
 </TABLE>
</TD>


</TR>
</TBODY>
</TABLE>
<DIV class=buttonArea><INPUT hideFocus class=formButton value="确  定" type=submit>&nbsp;&nbsp; <INPUT hideFocus class=formButton onclick="back()" value="返  回" type=button> </DIV>
</FORM>
</DIV>

</BODY>

<script type="text/javascript">
$().ready(function() {
	
	//初始化上传按钮
	$("#uploadify").uploadify( {//初始化函数
    'uploader' :'../js/uploadify.swf',//flash文件位置，注意路径
    'script' :'<%=request.getContextPath()%>/admin/advUpload.do',//后台处理的请求
    'cancelImg' :'../js/cancel.png',//取消按钮图片
    'folder' :'uploads',//您想将文件保存到的路径
    'queueID' :'fileQueue',//与下面的上传文件列表id对应
    'queueSizeLimit' :10,//上传文件的数量
    'fileDesc' :'jpg、png和gif文件',//上传文件类型说明
    'fileExt' :'*.jpg;*.jpeg;*.png;*.gif', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
    'method':'post',//如果向后台传输数据，必须是get
    'sizeLimit':10000000,//文件上传的大小限制，单位是字节
    'auto' :true,//是否自动上传
    'multi' :true,
    'simUploadLimit' :10,//同时上传文件的数量
    //'buttonText' :'上传',//浏览按钮图片
    'onComplete': function(event, queueID, fileObj,response,data) {//当上传完成后的回调函数，ajax方式哦~~ 	
       $(".advimg").attr("src","<%=request.getContextPath()%>"+response);
       $("#imgName").attr("value",response)
    }
   });		
   
    var $validateErrorContainer = $("#validateErrorContainer");
	var $validateErrorLabelContainer = $("#validateErrorContainer ul");
   // 表单验证
	$("#advForm").validate({
	    errorContainer: $validateErrorContainer,
		errorLabelContainer: $validateErrorLabelContainer,
		wrapper: "span",	   
		errorClass: "validateError",   
		rules: {
			imgName: "required",
			link: "required",	
			link1: "required",
			link2: "required",
			link3: "required",
			link4: "required",	
			sort: {required: true,digits: true}		
		},
		messages: {
			imgName: "请上传广告图片!",
			link: "请填写主链接!",	
			link1:"请填写link1!",
			link2:"请填写link2!",		
			link3:"请填写link3!",
			link4:"请填写link4!",	
			sort:{required:"请填写广告排序!",digits:"请填写合法的数字!"}
		},
		submitHandler: function(form) {			   
			$(form).find(":submit").attr("disabled", true);
			form.submit();
		}
	});
	
})

function back()
{
  window.history.back(); return false;
}
</script>
</html>